package com.leetcode.August;

/**
 * @Description: 162. 寻找峰值
 * @Author: Mr.Fxy
 * @CreateTime: 2024-09-02 13:56
 */
public class LC162寻找峰值 {
    public int findPeakElement(int[] nums) {
        int left = -1, right = nums.length - 1;
        while (left + 1 < right) {
            int mid = left + (right - left) / 2;
            if (nums[mid] > nums[mid + 1]) {
                right = mid;
            } else {
                left = mid;
            }
        }
        return right;
    }
}
